package com.example.demo

import android.content.Context
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.ui.unit.ExperimentalUnitApi
import androidx.lifecycle.viewmodel.compose.viewModel
import com.example.demo.view.AppNavigationView
import com.example.featuresdk.viewmodel.NavigationViewModel
import dagger.hilt.android.AndroidEntryPoint
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject

@AndroidEntryPoint
class MainActivity : ComponentActivity() {

    @Inject
    @ApplicationContext
    lateinit var context: Context

    lateinit var navigationViewModel: NavigationViewModel

    @OptIn(ExperimentalFoundationApi::class)
    @ExperimentalUnitApi
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            navigationViewModel = viewModel()
            AppNavigationView(navigationViewModel, context = context)
        }
    }

    override fun onBackPressed() {
        Log.i("MainActivity", "onBackPressed....${navigationViewModel.activeContextualFeatureKey.value}")
        //TODO: Put the app to background directly when the user is currently at the primary navigation
        super.onBackPressed()
    }
}

